//获取spu信息的接口文件
import request from '@/utils/request'

//获取spuList列表
export const reqSpuList=(page,limit,category3Id)=>{
  return request({url:`/admin/product/${page}/${limit}`,method:'get',params:{category3Id}})
}

//spuForm的四个初始化接口
// /admin/product/getSpuById/{spuId} get
// /admin/product/baseSaleAttrList get
// /admin/product/baseTrademark/getTrademarkList get
// /admin/product/spuImageList/{spuId} get

//获取spu信息接口
export const reqSpuInfo=(spuId)=>{
  return request({url:`/admin/product/getSpuById/${spuId}`,method:'get'})
}
//获取品牌列表信息
export const reqTradeMarkList=()=>{
  return request({url:`/admin/product/baseTrademark/getTrademarkList`,method:'get'})
}
//获取销售属性列表信息
export const reqSaleAttrList=()=>{
  return request({url:'/admin/product/baseSaleAttrList',method:'get'})
}
//获取spu商品信息的图片列表
export const reqSpuImageList=(spuId)=>{
  return request({url:`/admin/product/spuImageList/${spuId}`,method:'get'})
}

//保存或修改spuInfo
export const reqSaveOrUpdateSpuInfo=(spuInfo)=>{
  //有id，为修改
  if(spuInfo.id){
    return request({url:'/admin/product/updateSpuInfo',method:'post',data:spuInfo})
  }else{// 如果没有id，则为保存
    return request({url:'/admin/product/saveSpuInfo',method:'post',data:spuInfo})
  }
}
//删除spuInfo，byId
export const reqDeleteSpuInfo=(spuId)=>{
  return request({url:`/admin/product/deleteSpu/${spuId}`,method:'delete'})
}

//获取销售属性值列表
export const reqSpuSaleAttrList=(spuId)=>{
  return request({url:`/admin/product/spuSaleAttrList/${spuId}`,method:'get'})
}
//获取属性值列表
export const reqSpuInfoList=(category1Id,category2Id,category3Id)=>{
  return request({url:`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,method:'get'})
}
//保存skuInfo信息
export const reqSaveSkuInfo=(skuInfo)=>{
  return request({url:'/admin/product/saveSkuInfo',method:'post',data:skuInfo})
}

//获取sku列表数据
export const reqSkuList=(spuId)=>{
  return request({url:`/admin/product/findBySpuId/${spuId}`,method:'get'})
}



